const multer = require('multer');
const path = require("node:path");
const {getHexByLength} = require("../utils/generateHex");

const storage = multer.diskStorage({
    destination: './public/attachments',
    filename: function (req, file, cb) {
        cb(null, getHexByLength(12) + path.extname(file.originalname));
    }
});

const uploadAvatar = multer({
    storage: storage
});

module.exports = uploadAvatar;